package manager;


import java.util.Map;

import entity.BiddingEntity;
import entity.CommondityListEntity;
import entity.DeleteEntity;
import entity.ForgetPwdEntity;
import entity.LoginEntity;
import entity.PublicEntity;
import entity.RegisterEntity;
import entity.SavePictureEntity;
import entity.UpdateCommodityInfoEntity;
import entity.UserJoinCommodity;
import okhttp3.RequestBody;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.PartMap;
import rx.Observable;

/**
 * Created by Mr.Q on 2018/4/13.
 * 描述
 */

public interface ApiService {

    @FormUrlEncoded
    @POST("/commodity/user/add")
    Observable<RegisterEntity> register(@Field("account") String account,
                                        @Field("password") String password,
                                        @Field("name") String name,
                                        @Field("picturePath") String picturePath,
                                        @Field("sex") String sex);

    @FormUrlEncoded
    @POST("/commodity/user/update")
    Observable<LoginEntity> modify(@Field("account") String account,
                                        @Field("password") String password,
                                        @Field("name") String name,
                                        @Field("picturePath") String picturePath,
                                        @Field("sex") String sex,
                                        @Field("id") int id);

    @FormUrlEncoded
    @POST("/commodity/user/login")
    Observable<LoginEntity> login(@Field("account") String account,
                                  @Field("password") String password);

    @FormUrlEncoded
    @POST("/commodity/user/updatePassword")
    Observable<ForgetPwdEntity> forgetPwd(@Field("account") String account,
                                          @Field("password") String password);

    @FormUrlEncoded
    @POST("/commodity/commodity/auction")
    Observable<BiddingEntity> bidding(@Field("userId") String userId,
                                      @Field("commodityId") String commodityId);

    @POST("/commodity/user/saveFile")
    @Multipart
    Observable<SavePictureEntity> uploadFile(@PartMap Map<String, RequestBody> map);


    @POST("/commodity/commodity/add")
    @FormUrlEncoded
    Observable<PublicEntity> publishCommodity(@Field("userId") int userId,
                                              @Field("imagePath") String picPath,
                                              @Field("title") String title,
                                              @Field("startTime") String startTime,
                                              @Field("endTime") String endTime,
                                              @Field("startPrice") String startPrice,
                                              @Field("auctionGradient") String priceGradient,
                                              @Field("remark") String des);

    @POST("/commodity/commodity/update")
    @FormUrlEncoded
    Observable<UpdateCommodityInfoEntity> updateCommodityInfo(@Field("id") int id,
                                                              @Field("userId") int userId,
                                                              @Field("imagePath") String picPath,
                                                              @Field("title") String title,
                                                              @Field("startTime") String startTime,
                                                              @Field("endTime") String endTime,
                                                              @Field("startPrice") String startPrice,
                                                              @Field("auctionGradient") String priceGradient,
                                                              @Field("remark") String des);

    @POST("/commodity/commodity/page")
    @FormUrlEncoded
    Observable<CommondityListEntity> getCommodityList(@Field("page") int page,
                                                      @Field("rows") int rows,
                                                      @Field("state") String state);

    @POST("/commodity/commodity/page")
    @FormUrlEncoded
    Observable<CommondityListEntity> getMyPublishList(@Field("page") int page,
                                                      @Field("rows") int rows,
                                                      @Field("userId") int userId);

    @POST("/commodity/commodity/page")
    @FormUrlEncoded
    Observable<CommondityListEntity> getCommodityStateList(@Field("page") int page,
                                                           @Field("rows") int rows,
                                                           @Field("userId") int userId,
                                                           @Field("state") String state);


    @POST("/commodity/commodity/delete")
    @FormUrlEncoded
    Observable<DeleteEntity> deleteCommodity(@Field("id") int id);



    @POST("/commodity/commodity/findAllByUserId")
    @FormUrlEncoded
    Observable<UserJoinCommodity> userJoinCommodity(@Field("userId") String userId);


//    @FormUrlEncoded
//    @POST("/ticket/ticket/page")
//    Observable<TicketInfoEntity> getTicketList(@Field("startSite") String startSite,
//                                               @Field("endSite") String endSite,
//                                               @Field("date") String date,
//                                               @Field("page") int page,
//                                               @Field("rows") int rows);
//
//    @FormUrlEncoded
//    @POST("/ticket/ticket/deduct")
//    Observable<SubmitOrderEntity> submitOrder(@Field("id") String id,
//                                              @Field("ticketType") int ticketType,
//                                              @Field("num") int num);
//
//    @FormUrlEncoded
//    @POST("/ticket/order/add")
//    Observable<OrderSureEntity> getOrderSure(@Field("userId") String id,
//                                             @Field("ticketId") String ticketId,
//                                             @Field("num") int num,
//                                             @Field("ticketType") String ticketType);
//
//    @FormUrlEncoded
//    @POST("/ticket/order/findAll")
//    Observable<TravelEntity> getNoTravelOrder(@Field("userId") String userId,
//                                              @Field("state") String state);
//
//    @FormUrlEncoded
//    @POST("/ticket/order/update")
//    Observable<UpdateTicketState> updateTicketState(@Field("id") int id,
//                                                    @Field("state") String state);

}
